#!/usr/bin/env python
#==============================================================================
#
#  $Id$
#
"""
    Script to dump a database transaction logfile.
"""
#
#   Copyright (C) 2007 Michael A. Muller
#
#   This file is part of ODB.
#
#   ODB is free software: you can redistribute it and/or modify it under the 
#   terms of the GNU Lesser General Public License as published by the Free 
#   Software Foundation, either version 3 of the License, or (at your option) 
#   any later version.
#
#   ODB is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU Lesser General Public License for more details.
#
#   You should have received a copy of the GNU Lesser General Public License 
#   along with ODB.  If not, see <http://www.gnu.org/licenses/>.
#
#==============================================================================

import sys, struct
from cStringIO import StringIO
from pickle import Unpickler

src = file(sys.argv[1], 'rb')
while True:
    data = src.read(4)
    if not data:
        break
    size = struct.unpack('I', data)[0]
    data = src.read(size)
    txn = Unpickler(StringIO(data)).load()
    txn.dump(sys.stdout)



